﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Controls.Maps;
using System.Diagnostics;
using System.Device.Location;

namespace unifiqAnthony
{
    public partial class ShowMap : PhoneApplicationPage
    {
        internal const string id = "AoetA0820tVc4COdo9bGyEKy0mBSDjoSeb9vlIRP3iC3RWibRFlwOGPGVLOUn7Fs";
        private readonly CredentialsProvider _credentialsProvider = new ApplicationIdCredentialsProvider(id);

        public CredentialsProvider CredentialsProvider
        {
            get { return _credentialsProvider; }
        }

        public ShowMap()
        {
            InitializeComponent();

        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string location = NavigationContext.QueryString["location"];
            double lat = Convert.ToDouble(NavigationContext.QueryString["lat"]);
            double lng = Convert.ToDouble(NavigationContext.QueryString["lng"]);

            MapLayer layer = new MapLayer();
            Pushpin pin = new Pushpin();
            GeoCoordinate loc = new GeoCoordinate(lat, lng);
            pin.Location = loc;
            pin.Template = this.Resources["location_marker"] as ControlTemplate;
            pin.Name = location;

            showMap.Center = new System.Device.Location.GeoCoordinate(lat, lng);
            showMap.ZoomLevel = 13;
            layer.Children.Add(pin);
            showMap.Children.Add(layer);
        }

    }
}